#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
const int N = 1e6 + 10;
typedef long long LL;
LL a[N];
LL n, m;
LL cal(LL x)
{
	LL cnt = 0;
	for (int i = 1; i <= n; i++)
		if (a[i] > x)cnt += a[i] - x;
		//cnt += ((a[i] - mid) > 0 ? a[i] - mid : 0);
	return cnt;
}
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> a[i];
	LL left = 0, right = 2e9;
	while (left < right)
	{
		LL mid = (left + right + 1)/ 2;
		if (cal(mid) >= m) left = mid;
		else right = mid - 1;
	}
	cout << left << endl;
	return 0;
}